import folderIcon from '@/assets/image/ext/folder.png'
import iconVideo from '@/assets/image/ext/video.png'
import iconAudio from '@/assets/image/ext/audio.png'
import icon7z from '@/assets/image/ext/7z.png'
import iconGz from '@/assets/image/ext/gz.png'
import iconIso from '@/assets/image/ext/iso.png'
import iconRar from '@/assets/image/ext/rar.png'
import iconTar from '@/assets/image/ext/tar.png'
import iconZip from '@/assets/image/ext/zip.png'
import iconCsv from '@/assets/image/ext/csv.png'
import iconDoc from '@/assets/image/ext/doc.png'
import iconDocx from '@/assets/image/ext/docx.png'
import iconHtml from '@/assets/image/ext/html.png'
import iconMd from '@/assets/image/ext/md.png'
import iconPdf from '@/assets/image/ext/pdf.png'
import iconPpt from '@/assets/image/ext/ppt.png'
import iconPptx from '@/assets/image/ext/pptx.png'
import iconTxt from '@/assets/image/ext/txt.png'
import iconXls from '@/assets/image/ext/xls.png'
import iconXlsx from '@/assets/image/ext/xlsx.png'

const SuffixMap: Record<string, string> = {
    folder: folderIcon,
    // 文档
    csv: iconCsv,
    docx: iconDocx,
    doc: iconDoc,
    html: iconHtml,
    md: iconMd,
    pdf: iconPdf,
    ppt: iconPpt,
    pptx: iconPptx,
    xlsx: iconXlsx,
    xls: iconXls,
    txt: iconTxt,
    // 压缩包
    '7z': icon7z,
    iso: iconIso,
    rar: iconRar,
    tar: iconTar,
    zip: iconZip,
    gz: iconGz,
    // 视频
    mp4: iconVideo,
    wmv: iconVideo,
    avi: iconVideo,
    mpg: iconVideo,
    mpeg: iconVideo,
    mov: iconVideo,
    m4v: iconVideo,
    flv: iconVideo,
    rmvb: iconVideo,
    mkv: iconVideo,
    // 音频
    mp3: iconAudio,
    wav: iconAudio,
    aac: iconAudio,
    ogg: iconAudio,
    ape: iconAudio,
    ac3: iconAudio,
    m4a: iconAudio,
    amr: iconAudio,
    wma: iconAudio,
    mid: iconAudio,
    midi: iconAudio,
    flac: iconAudio
}

const suffixUtil = {
    findUnitIcon(name: string) {
        if (name) {
            const suffix: string | undefined = name.split('.').pop()
            for (const nameKey in SuffixMap) {
                if (suffix?.includes(nameKey)) {
                    return SuffixMap[nameKey]
                }
            }
        }
        return SuffixMap.folder
    }
}

export default suffixUtil
